"""
@author: 江同学呀
@file: annotated_text_field.py
@date: 2024/7/27 23:47
@desc:
    https://www.elastic.co/guide/en/elasticsearch/plugins/7.17/mapper-annotated-text.html

    Text containing special markup. Used for identifying named entities.
    包含特殊标记的文本。用于标识命名实体。
"""
from abc import ABC
from typing import Type, Union, Dict

from espc.orm.model.base.base import _Base
from espc.orm.model.mapping.field.base_field.base_string_field import _BaseStringField
from espc.utils.build_add_attr import build_add_attr


class AnnotatedTextField(_BaseStringField, ABC):
    """
    特殊标记文本 字段
    todo 特殊字段类型，未仔细研究文档
    """
    _field_type: str = "annotated-text"

    def __init__(self, field_name: str = None, value: str = None, default: Dict = None):
        super().__init__(field_name=field_name, value=value, default=default)
        return

    def __get__(self, instance: _Base, owner: Type["AnnotatedTextField"]) -> Union["AnnotatedTextField", str]:
        return super(AnnotatedTextField, self).__get__(instance=instance, owner=owner)

    def __set__(self, instance, value: str):
        super(AnnotatedTextField, self).__set__(instance=instance, value=value)
        return

    @build_add_attr
    def _build(self) -> Dict:
        raise NotImplementedError(f"{self.__class__.__name__}：特殊字段类型，未仔细研究文档")







